package com.zuipin.framework.emuns;

/**
 * 
 * @Title: ErrorCode
 * @Package: com.zuipin.framework.emuns
 * @author: zengxinchao
 * @date: 2017年3月9日 上午10:04:34
 * @Description: 请在这里添加各种状态码，添加前请确认有必要添加
 * 按code顺序添加，code请保证唯一，message请用英文做必要说明
 */
public enum ErrorCode {
	
	SUCCESS(0, "success", "成功"), //
	ILLEGAL_PARAM(1001, "illegal paramer", "参数错误"), //
	PARAM_ABSENT(1002, "necessary paramer absent", "必填参数为空"), //
	DB_EXCEPTION(1003, "database exception", "数据库异常"), //
	EXCEPTION(1004, "system exception", "系统异常"), //
	ELSE(1000, "other reason", "其他原因"), //
	NOT_FIND(2000, "object is not find", "对象没有找到"), //
	NULL_POINT(2001, "null point", "空指针"), //
	ORDER_ERRPR(3000, "order error", "订单错误"), //
	OBJECT_EXIST(3005, "object is exist", "对象存在"), //
	MEMBER_NOT_EXIST(3006, "member is not exist", "用户不存在"), //
	MEMBER_ACCOUNT_NOT_EXIST(3007, "memberAccount is not exist", "用户帐号不存在"), //
	PHONE_IS_BINDING(3008, "Binding mobile phone number has been bound to another account", "绑定手机号码已经绑定到另一个帐号"), //
	THIRD_ACCOUNT_NOT_EXIST(3009, "thirdAccount is not exist", "第三方帐号不存在"), //
	PASSWORD_ERROR(3010, "memberAccount is error or password is error", "帐号或密码错误"), //
	OLD_IS_NOT_EQUALS_NEW(3011, "new password is not equals old password", "新密码不能等于旧密码"), //
	RULE_ONLY_GET_ONE(3012, "the same rules can only receive a red envelope", "相同的规则只能使用一个红包"), //
	RULE_NO_RED_PACKET(3013, "rule no redPacket", "红包数量已派发完毕，不能派发"), //
	ON_SHELF(4001, "commodity did not on shelf", "商品已下架"), //
	STORAGE_INSUFFICIENT(4002, "storage insufficient", "库存不足"), //
	NO_COMMODITY(4003, "there is no commodity in shoppingcart", "购物车中没有商品"), //
	NO_MATCH_COMMODITY(4004, "no matched commodity", "无匹配商品"), //
	NO_SHIPPING_ADDRESS(4005, "there is no shipping address", "没有送货地址"), //
	PAY_METHOD_NOT_EXISTS(4006, "pay method not exists", "支付方式不存在"), //
	DELIVERY_NOT_EXISTS(4007, "delivery method not exists", "配送方式不存在"), //
	REDPACKET_INVALID(4009, "redpacket invalid", "该红包已失效"), //
	REDPACKET_CANNOT_USE(4010, "redpacket can not use", "该红包不能使用"), //
	NO_BIND_PHONE(4011, "did not bind phone", "没有绑定手机"), //
	ADDRESS_NO_BIND_PHONE(4012, "shipping address did not binded the phoneNum", "该送货地址没有绑定手机号"), //
	STORAGE_SYS_EXCEPTION(4013, "storage system exception", "库存系统异常"), //
	STORAGE_REQUEST_FAILED(4014, "storage request is failed", "库存请求失败"), //
	STORAGE_INFO_BACK_FAILED(4015, "storage info back is failed", "库存信息返回失败"), ///
	NO_STORAGE_INFO(4016, "not storage info", "没有库存信息"), //
	UPDATE_CART_FULL_STORAGE(4017, "update shopping cart storage is full", "购物车空间已满"), //
	RED_PACKET_NULL(4018, "red packet is null", "红包为空"), //
	EMS_NO_CASH_DELIVERY(4019, "ems is not support cash on delivery", "ems不支持货到付款"), //
	RULE_NULL(4020, "rule is null", "规则不存在"), //
	DRAW_FAIL(4021, "draw fail", "抽奖失败"), //
	ENTER_ACCOUNT_ERROR(4030, "You enter the account mistakes", "帐户输入错误"), //
	// 两个账号分别绑定不同手机号，无法修改
	MOBILE_PHONE_NOT_UPDATE(4031, "Two accounts respectively different binding mobile phone number, cannot be modified", "两个账号分别绑定手机号码,不能修改"), //
	// 该手机号已经存在一个相同平台的第三方账号
	MOBILE_PHONE_EXIST_SAME_THIRD(4032, "The phone number already has a third-party account on the same platform", "该手机号已在同一平台上拥有第三方帐户"), //
	PRODUCT_DISABLED(5001, "The product has been disabled", "该产品已下架"), //
	STATE_INVALID(5002, "Invalid status value", "无效的状态值"), //
	ORDER_EVALUATED(5101, "Order has been evaluated", "订单已审核"), //
	AT_LEAST_FILL_PRODUCT_EVALUATION(5102, "At least fill in a product evaluation", "至少填写一项产品评价"), //
	REPEATED_EVALUATION(5003, "Repeated evaluation", "重复审核"),
	// 发票信息不完整
	ORDER_INVOICE_INCOMPLETE(4033, "The invoice information is incomplete", "发票信息不完整"), //
	MEMBER_LEVEL_IS_NULL(4034, "memberLevel is null", "会员等级不能为空"), //
	MEMBER_ID_IS_ERROR(4035, "memberId is error or orderNo is error", "会员ID或订单编号错误"), //
	SYS_ID_IS_ERROR(4036, "sysId is error or orderNo is error", "系统ID或订单编号错误"), //
	ORDER_IS_NOT_EXIST(4037, "orderNo is not exist", "订单编号不存在"), //
	ORDER_FINISH_IN_DELIVERY(4038, "order only finish in delibery", "订单只能在收货后完成"), //
	ORDER_PAY_FINISH(4039, "order is pay finish,not alter internalDiscountSum", "订单已完成,不能修改内部优惠"), //
	RULE_ARE_OUTDATED(4041, "Rules are outdated", "规则已过期"), //
	LEVEL_IS_NOT_GET(4042, "the current level is not get", "未达到当前等级"), //
	RULE_GET_NUM_OUT(4043, "Get the number beyond the limit", "获取数量超出限制"), //
	REDPACKET_ACTIVATED(4044, "Coupons have been activated elsewhere", "优惠券已被激活"), //
	MSG_ERROR(6001, "msg error", "msg错误"), //
	RULE_NOT_MODITY(7001, "rule modity only not active", "只能修改未激活的规则"), //
	RULE_NOT_MODITY_STATUS(7002, "cannot enable or disable the rule", "无法启用或禁用规则"), //
	RULE_SPECIAL_PRO_NULL(7003, "the special rule product null", "特价规则产品为空"), //
	RULE_SPECIAL_PRO_MANY(7004, "many special rule ", "特价规则过多"), //
	RULE_MAX_PROBABILITY_ERROR(7005, " max 100% ", "最大概率为100%"), //
	RULE_STATUS_NO_ENABLE(7006, "rule status no enable", "规则状态未激活"), // ;
	RULE_OUT_TIME(7007, "time is out of line", "未开始"), //
	RULE_OUT_MEMBER_LEVEL(7008, "member level is out of line", "会员级别未达到"), //
	DRAW_NUM_OUT(7009, "draw num is out of line", "没有抽奖次数了"), //
	RULE_DEVICE(7010, "draw device is out of line", "抽奖平台错"), //
	PRIZE_NULL(7011, "prize null", "奖品数量为空"), //
	RULE_BEYOND_LIMIT_NUM(4045, "Beyond the purchase quantity", "超出购买数量"), //
	RULE_BEYOND_LIMIT_BILL(4046, "Beyond limit bill.", "超过帐单限额"), //
	RULE_SYSTEM_RESTRICTION(4047, "system restriction", "系统限制"), //
	RULE_DEVICE_RESTRICTION(4048, "device restriction", "平台限制"), //
	COUNTENOUGH_OR_NOSAL(4049, "all product count is empty or is no sale", "所有产品库存不足或已下架"), //
	PART_ENOUGH(4050, "part of prouduct count is empty or is no sale", "部分产品库存不足或已下架"), //
	RUEL_CONDLICT_REDPACKET(4051, "redpacket conflict rule", "红包规则冲突"), //
	RULE_LIMIT_PRO_NULL(4052, "rule limit pro null", "规则限制的商品为空"), //
	RULE_NOT_SARISFY(4053, "rule not satisfy amount or num ", "数量或金额不符"), //
	FREE_POSTAGE_CONDIRION_FALSE(4054, "free postage null ", "免邮类型为空"), //
	COUNTEMPTY_OR_NOSAL(4049, "all product count is empty or is no sale", "所有产品库存不足或已下架"), //
	RULE_DISABLE(4060, "the rule disable", "规则禁用"), //
	RULE_DRAWTIME_OUTDATED(4061, "Rules are outdated", "领取时间过期"), //
	TOTAL_AMOUNT_OUT_OF(3002, "total amount out of line", "余额小于0"), //
	MODITY_STATUS_FAIL(8000, "modity status fail", "修改状态失败"), //
	MODITY_EXPRESS_FAIL(8001, "modity  express fail", "填写快递信息失败"), //
	MODITY_INVOICE_FAIL(8002, "modity  invoice fail", "填写发票信息失败"), //
	ORDER_NOT_OWNER(3999, "you not owner", "不是订单的所有者"), //
	BUY_LOWER_OUT(4062, "buy of product exceeds the lower limit", "购买商品未达到最低定购量"), //
	BUY_UPPER_OUT(4063, "buy of goods exceeds the upper limit", "购买商品超过最高定购量"), //
	MEMBER_IS_FREEZE(4064, "member is freeze", "会员被冻结"), //
	SHOPPING_CART_CANNOT_SUBMIT(4065, "shopping cart cannot submit", "部份商品不符合购物车提交规则，无法提交！"), //
	MODITY_BRAND_FAIL(9002, "modity  brand fail", "修改品牌信息失败"), //
	MODITY_PROP_FAIL(9003, "modity  prop fail", "修改属性信息失败"), //
	MODITY_CAT_PROP_FAIL(9004, "modity  cat prop fail", "修改分类属性信息失败"), //
	PROP_IS_DISABLE(9005, "properties is disable", "该属性已被禁用"), //
	MODITY_MEMBER_FAIL(9006, "modity  member fail", "修改会员信息失败"), //
	MODITY_INTEGRAL_OR_BALANCE_FAIL(9005, "modity  integral or balance fail", "修改余额或积分信息失败"), //
	;
	
	private int		code;
	private String	message;
	private String	cnMessage;
	
	private ErrorCode(int code) {
		this.code = code;
	}
	
	private ErrorCode(int code, String message, String cnMessage) {
		this.code = code;
		this.message = message;
		this.cnMessage = cnMessage;
	}
	
	public String getMessage() {
		return message;
	}
	
	public int getCode() {
		return code;
	}
	
	public String getCnMessage() {
		return cnMessage;
	}
	
	public void setCnMessage(String cnMessage) {
		this.cnMessage = cnMessage;
	}
	
	public static ErrorCode getErrorCodeByCode(Integer code) {
		for (ErrorCode errorCode : ErrorCode.values()) {
			if (code.equals(errorCode.getCode())) {
				return errorCode;
			}
		}
		return null;
	}
	
}
